#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<cmath>
using namespace std;
int jc(int n);
int main() {
	int m, n;
	double x;
	cin >> m;
	for (int i = 0; i < m; i++) {
		double num, sum = 0;
		cin >> x >> n;
		for (int j = 1; j <= n; j++) {
			double X = pow(x, j);
			int jieceng = jc(j);
			if (j % 2 == 0) {
				num = (double)(X / jieceng);
			}
			if (j % 2 != 0) {
				num = (double)((-1) * (X / jieceng));
			}
			sum += num;
		}
		cout << fixed << setprecision(3) << sum << endl;
	}
	return 0;
}
int jc(int n) {
	int jieceng = 1;
	for (int i = 1; i <= n; i++) {
		jieceng *= i;
	}
	return jieceng;
}


/*
#include<iostream>
using namespace std;
int main(){
	int m;
	cin>>m;
	for(int i=0;i<m;i++){
		int n;
		double x;
		double num=1.0,sum=0.0;
		cin>>x>>n;
		for(int j=1;j<=n;j++){
			num=num*x/j;
			if(j%2==0){
				sum+=num;
			}
			if(j%2!=0){
				sum-=num;
			}
		}
		printf("%.3f\n",sum);
	}
	return 0;
}  */